/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/5/20 20:57
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.template.pattern.command.base;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-08-25 20:30
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-08-25
 * @modify reason: {方法名}:{原因}
 * ...
 */
public abstract class AbstractRemoteController<T,K extends Command> {

    protected K undoCommand;

    /**开启操作命令数组*/
    protected K[] onCommands;
    /**关闭操作命令数组*/
    protected K[] offCommands;

    public boolean supportUndo(){
        return true;
    }

    /**
     * 设置命令
     * @param index
     * @param onCommand
     * @param offCommand
     */
    public abstract void setCommand(int index, T onCommand, T offCommand);


    /**
     * 遥控按钮被按下时，执行命令
     */
    public abstract void buttonWasPressed(int index);

    /**
     * 开启操作的撤销按钮
     */
    public  void undoButtonWasPressed(){
        if(supportUndo()){
            undoCommand.execute();
        }
    }
}
